package net.wangds.yunz.initialize.flow;

import net.wangds.log.helper.LogHelper;
import net.wangds.procengine.ProcResEnum;
import net.wangds.procengine.flow.define.SimpleFlow;
import net.wangds.procengine.flow.define.actor.ActorDef;
import net.wangds.procengine.flow.define.node.FlowNode;
import net.wangds.procengine.flow.define.node.JavaFlowNode;
import net.wangds.spring.utils.SpringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

/**
 * .
 * <p></p>
 *
 * @author 王东石 2020/10/18 9:28.
 */
@Service
@Lazy
public class FlowInitApplicatons extends SimpleFlow<ActorDef> {

    /*
     * 装配流程.
     */
    @Override
    protected synchronized void combine() {
        super.combine();

        this.setFlowId("InitApplications");
        this.setFlowName("初始化应用");

        //输出流程启动日志
        FlowNode ndBegin = new JavaFlowNode(this, (c, a)->{
            LogHelper.dev("启动"+getFlowName()+"过程");
            return ProcResEnum.CONTINUE;
        }, null);
        this.addFlowNode(ndBegin);

        //初始化步骤
        FlowNode stepInitApplication = SpringUtils.getBean(StepInitApplications.class, this, ndBegin);
        this.addFlowNode(stepInitApplication);

        // 设置清理过程
        this.setOnHouseKeeping((c,a)-> {
        });

    }
}
